﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RoadTeam.SysInterface;
using RoadTeam.Model;
using RoadTeam.Enums;
using System.Data;
namespace RoadTeam.BsSystem.SM
{
    public class SmOrgan_Sys :RtSysBase, ISmOrgan
    {
        public String GetOraganID(String OraganIdentifier)
        {
            SqlWhere where = new SqlWhere();
            where.Info = new Model.TbSmOrgan() { OrganIdentifier = OraganIdentifier };
            where.SelectColumn = @" Top 1 OrganID ";
            DataTable dt = TbSmOrgan.Select(where, GlobalConfig.RtConnectionString);
            if (dt.Rows.Count == 0) return @"-1";
            return dt.Rows[0][0].ToString();
        }

        public override string GetIdentitiferByID(String ID)
        {
            SqlWhere where = new SqlWhere();
            where.Info = new Model.TbSmOrgan() { OrganID = ID };
            where.SelectColumn = @" Top 1 OrganIdentifier ";
            DataTable dt = TbSmOrgan.Select(where, GlobalConfig.RtConnectionString);
            if (dt.Rows.Count == 0) return @"-1";
            return dt.Rows[0][0].ToString();
        }

        public DataTable GetALLOraganTable()
        {
            SqlWhere where = new SqlWhere();
            where.Info = new Model.TbSmOrgan();
            where.SelectColumn = @"   OrganID,OrganIdentifier ";
            DataTable dt = TbSmOrgan.Select(where, GlobalConfig.RtConnectionString);
            return dt;
        }




        public DataTable GetOrganTable()
        {
            SqlWhere where = new SqlWhere();
            where.SelectColumn = @"OrganID,OrgCode,OrgName,OrganIdentifier";
            where.StrSqlWhere = @" OrganIdentifier is null  ";
            return TbSmOrgan.Select(where, GlobalConfig.RtConnectionString);
        }

        public bool UpdateOrganInfo(DataTable dt)
        {
           return   TbSmOrgan.Update(dt, GlobalConfig.RtConnectionString);
        }


    }
}
